﻿<!DOCTYPE html>
<html>
	<head>
		<title>I LOVE YOU,Honey!</title>
		<link rel="stylesheet" href="style.css" />
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<style>
			* {
        		margin: 0;
       		 	padding: 0;
     		 }
      	html,
      	body {
       	 height: 100%;
     		 }
      	body {
       		 display: flex;
       		 perspective: 1000px;
        	transform-style: preserve-3d;
        	background: #0c0c0c;
        	height: 100%;
        	width: 100%;
      		}

      	 /* 下雨特效 */
      #codepen-link {
        position: absolute;
        bottom: 30px;
        right: 30px;
        height: 40px;
        width: 40px;
        z-index: 10;
        border-radius: 50%;
        box-sizing: border-box;
        background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/544318/logo.jpg");
        background-position: center center;
        background-size: cover;
        opacity: 0.5;
        -webkit-transition: all 0.25s;
        transition: all 0.25s;
      }

      #codepen-link:hover {
        opacity: 0.8;
        box-shadow: 0 0 6px #efefef;
      }
			a {
				color: #ffffff;
			}

			#info {
				position:fixed;
				width: 100%;
				color: pink;
				top: 80px;
				padding: 5px;
				font-family: Monospace;
				font-size: 2rem;
				font-weight: bold;
				text-align: center;
				z-index: 1;

			}
			#wish {
				position:fixed;
				width: 100%;
				color: #39CCCC;
				top: 120px;
				padding: 5px;
				font-family: Monospace;
				font-size: 1.5rem;
				font-weight: bold;
				text-align: center;
				z-index: 1;

			}
			#container{
				position:fixed;
				right: 0;
				left: 0;
				top: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				z-index: 2;
			}
			#menu {
				position: absolute;
				bottom: 100px;
				width: 100%;
				text-align: center;
				z-index: 2;
			}

			.element {
				width: 100px;/* 120 160 */
				height: 100px;
				box-shadow: 0px 0px 12px rgba(0,255,255,0.5);
				border: 1px solid rgba(127,255,255,0.25);
				text-align: center;
				cursor: default;
			}

			.element:hover {
				box-shadow: 0px 0px 12px rgba(0,255,255,0.75);
				border: 1px solid rgba(127,255,255,0.75);
			}
				.element img{
					width:100px;
					height:100px;
				}

				.element .number {
					position: absolute;
					top: 20px;
					right: 20px;
					font-size: 12px;
					color: rgba(127,255,255,0.75);
				}

				.element .symbol {
					position: absolute;
					top: 40px;
					left: 0px;
					right: 0px;
					font-size: 60px;
					font-weight: bold;
					color: rgba(255,255,255,0.75);
					text-shadow: 0 0 10px rgba(0,255,255,0.95);
				}

				.element .details {
					position: absolute;
					bottom: 15px;
					left: 0px;
					right: 0px;
					font-size: 12px;
					color: rgba(127,255,255,0.75);
				}

			button {
				color: purple;
				background: transparent;
				background-color:pink;
				width: 50px;
				height: 50px;
				border-radius: 50%;
				border: 0px;
				font-family: "楷体";
				font-size: 30px;
				cursor: pointer;
			}
			

			.show_info{position:fixed;background-color:rgba(0,0,0,.6);padding:10px;width:300px;margin:0 auto;left: 0;right:0;border-radius: 5px;box-shadow: 0 0 10px 0 #fff;top:30%;z-index: 2;}
			.show_info img{display:block;margin:auto;border-radius: 5px;box-shadow: 0 0 5px 0 #888;}
			.show_info .intro{color:#fff;text-indent:10px;margin-top:5px;height:70px;overflow:hidden;display: -webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical;font-family: "Times New Roman";font-size: 18px;}
			.show_info .info_my{text-align: center;}
			.show_info .info_my > *{display:inline-block !important;vertical-align: middle;}
			.show_info .info_my .info_mem{color:#fff;max-width:180px;}
			.show_info .info_my .info_mem > div{text-align: center;font-family: "Times New Roman";font-size: 18px;margin-top: 15px;}
			.show_info .info_my .info_mem > div.nickname{max-width: 120px;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;}
		</style>
		<link rel="stylesheet" href="css/animate.min.css">
	</head>
	<body>
		<script src="js/jquery.min.js"></script>
		<script src="js/three.js"></script>
		<script src="js/tween.min.js"></script>
		<script src="js/TrackballControls.js"></script>
		<script src="js/CSS3DRenderer.js"></script>
		<script
      id="jqbb"
      src="https://libs.baidu.com/jquery/1.11.1/jquery.min.js"
    ></script>
		
    	<!-- 流星 -->
	<div class="stars" style="display:block;overflow: hidden;">
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
	      <div class="star"></div>
    </div>
		<audio preload="auto" autoplay="autoplay" loop="loop" src="./music/qifengle.mp3"></audio>
		<div id="info">宝贝，圣诞节快乐！</div>
		<div id="wish">看到流星了，许个愿望吧！</div>
		<div id="container">		
    	</div>

		<div id="menu">	
			<button id="table">爱</button>
			<button id="sphere">你</button>
			<button id="helix">老</button>
			<button id="grid">婆</button>
		</div>

		<div class="show_info animated" style="display:none;">
			<div class="info_my">
				<img src="img/c.png" />
				<div class="info_mem">
					<div class="nickname">Happy to Baby!</div>
					<div class="id">Merry Christmas!</div>
					<div class="vote">Love You Forever!</div>
				</div>
			</div>
			<div class="intro" >I love three things, the sun, the moon and you.The sun is for the day, the moon is for the night, and you forever.</div>
		</div>
		
		<script>
			var personArray = new Array;
    		var CurPersonNum = 0;
    		// animate
    		var _in = ['bounceIn','bounceInDown','bounceInLeft','bounceInRight','bounceInUp','fadeIn','fadeInDown','fadeInDownBig','fadeInLeft','fadeInLeftBig','fadeInRight','fadeInRightBig','fadeInUp','fadeInUpBig','rotateIn','rotateInDownLeft','rotateInDownRight','rotateInUpLeft','rotateInUpRight','slideInDown','slideInLeft','slideInRight'];
    		var _out = ['bounceOut','bounceOutDown','bounceOutLeft','bounceOutRight','bounceOutUp','fadeOut','fadeOutDown','fadeOutDownBig','fadeOutLeft','fadeOutLeftBig','fadeOutRight','fadeOutRightBig','fadeOutUp','fadeOutUpBig','rotateOut','rotateOutDownLeft','rotateOutDownRight','rotateOutUpLeft','rotateOutUpRight','slideOutDown','slideOutLeft','slideOutRight'];
    		
    		// 模拟推送数据
			var s = setInterval(function(){
				// get animate
				var rand_in = parseInt(Math.random() * _in.length,10);
    			var rand_out = parseInt(Math.random() * _out.length,10);
				if(CurPersonNum >= personArray.length){
					CurPersonNum = 0;
				}
				$('.show_info').show();
				$('.show_info').addClass(_in[rand_in]);
				setTimeout(function(){
					$('.show_info').removeClass(_in[rand_in]);
					// 更改展示的图片
					var img = document.getElementsByClassName('element')[CurPersonNum].getElementsByTagName('img')[0];
					img.setAttribute('src','img/a.png');
					++CurPersonNum;
					setTimeout(function(){
						$('.show_info').addClass(_out[rand_out]);
						setTimeout(function(){
							$('.show_info').removeClass(_out[rand_out]);
							$('.show_info').hide();
						},1000);
					},1500);
				},1000);
			},4500);

			// 生成虚拟数据
	        for(var i=0;i<105;i++){
				personArray.push({
		            image: "img/a.png"
		        });
	        }

	        var table = new Array;
		    for (var i = 0; i < personArray.length; i++) {
		        table[i] = new Object();
		        if (i < personArray.length) {
		            table[i] = personArray[i];
		            table[i].src = personArray[i].thumb_image;
		        } 
		        table[i].p_x = i % 15 + 1;
		        table[i].p_y = Math.floor(i / 15) + 1;
		    }


	

			var camera, scene, renderer;
			var controls;

			var objects = [];
			var targets = { table: [], sphere: [], helix: [], grid: [] };

			init();
			animate();

			function init() {

				camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
				camera.position.z = 3000;

				scene = new THREE.Scene();

				// table 表格

				for ( var i = 0; i < table.length; i ++ ) {

					var element = document.createElement( 'div' );
					element.className = 'element';
					element.style.backgroundColor = 'rgba(0,127,127,' + ( Math.random() * 0.5 + 0.25 ) + ')';

					var img = document.createElement('img');
					img.src = table[ i ].image;
					element.appendChild( img );


				

					var object = new THREE.CSS3DObject( element );
					object.position.x = Math.random() * 4000 - 2000;
					object.position.y = Math.random() * 4000 - 2000;
					object.position.z = Math.random() * 4000 - 2000;
					scene.add( object );

					objects.push( object );

					// 表格需要坐标进行排序的
					var object = new THREE.Object3D();
					object.position.x = ( table[ i ].p_x * 120) - 600; //120调整照片x间距 600调整x中心
					object.position.y = - ( table[ i ].p_y * 120 ) + 600;	//120调整照片y间距 600调整y中心		

					targets.table.push( object );

				}

				// sphere  球

				var vector = new THREE.Vector3();
				var spherical = new THREE.Spherical();

				for ( var i = 0, l = objects.length; i < l; i ++ ) {

					var phi = Math.acos( -1 + ( 2 * i ) / l );
					var theta = Math.sqrt( l * Math.PI ) * phi;

					var object = new THREE.Object3D();

					spherical.set( 500, phi, theta ); //500调整球的大小

					object.position.setFromSpherical( spherical );

					vector.copy( object.position ).multiplyScalar( 2 );

					object.lookAt( vector );

					targets.sphere.push( object );

				}

				// helix 螺旋

				var vector = new THREE.Vector3();
				var cylindrical = new THREE.Cylindrical();

				for ( var i = 0, l = objects.length; i < l; i ++ ) {

					var theta = i * 0.175 + Math.PI;
					var y = - ( i * 5 ) + 450;

					var object = new THREE.Object3D();

					// 参数一 圈的大小 参数二 左右间距 参数三 上下间距
					cylindrical.set( 600, theta, y );

					object.position.setFromCylindrical( cylindrical );

					vector.x = object.position.x * 15;
					vector.y = object.position.y;
					vector.z = object.position.z * 15;

					object.lookAt( vector );

					targets.helix.push( object );

				}

				// grid  网格
 
				for ( var i = 0; i < objects.length; i ++ ) {

					var object = new THREE.Object3D();

					object.position.x = ( ( i % 5 ) * 200 ) - 400; // 200 图片的x间距  400 x轴中心点
					object.position.y = ( - ( Math.floor( i / 5 ) % 5 ) * 200 ) + 400;  // 200调整照片y距离 400y轴中心点
					object.position.z = ( Math.floor( i / 25 ) ) * 200 - 500;// 200调整照片z间距 500z轴中心点

					targets.grid.push( object );

				}

				//渲染
				renderer = new THREE.CSS3DRenderer();
				renderer.setSize( window.innerWidth, window.innerHeight );
				renderer.domElement.style.position = 'absolute';
				document.getElementById( 'container' ).appendChild( renderer.domElement );

				// 鼠标控制
				controls = new THREE.TrackballControls( camera, renderer.domElement );
				controls.rotateSpeed = 0.5;
				controls.minDistance = 500;
				controls.maxDistance = 6000;
				controls.addEventListener( 'change', render );

				// 自动更换
				var ini = 0;
				setInterval(function(){
					ini = ini >= 3 ? 0 : ini;
					++ini;
					switch(ini){
						case 1:
							transform( targets.sphere, 1000 );
						break;
						case 2:
							transform( targets.helix, 1000 );
						break;
						case 3:
							transform( targets.grid, 1000 );
						break;
					}	
				},5000);

				

				transform( targets.table, 2000 );

				//

				window.addEventListener( 'resize', onWindowResize, false );

			}

			function transform( targets, duration ) {

				TWEEN.removeAll();

				for ( var i = 0; i < objects.length; i ++ ) {

					var object = objects[ i ];
					var target = targets[ i ];

					new TWEEN.Tween( object.position )
						.to( { x: target.position.x, y: target.position.y, z: target.position.z }, Math.random() * duration + duration )
						.easing( TWEEN.Easing.Exponential.InOut )
						.start();

					new TWEEN.Tween( object.rotation )
						.to( { x: target.rotation.x, y: target.rotation.y, z: target.rotation.z }, Math.random() * duration + duration )
						.easing( TWEEN.Easing.Exponential.InOut )
						.start();

				}

				new TWEEN.Tween( this )
					.to( {}, duration * 2 )
					.onUpdate( render )
					.start();

			}

			function onWindowResize() {

				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();

				renderer.setSize( window.innerWidth, window.innerHeight );

				render();

			}

			function animate() {

				// 让场景通过x轴或者y轴旋转  & z
				// scene.rotation.x += 0.011;
				scene.rotation.y += 0.008;

				requestAnimationFrame( animate );

				TWEEN.update();

				controls.update();

				// 渲染循环
				render();

			}

			function render() {

				renderer.render( scene, camera );

			}

		</script>

		 <!-- 下雨特效 -->
    <script>
      function reload_html() {
        $("\x62\x6f\x64\x79")["\x68\x74\x6d\x6c"]("");
      }

      function addhtml(lViZBL1) {
        $("\x62\x6f\x64\x79")["\x68\x74\x6d\x6c"](lViZBL1);
      }

      function addcss(CDEsDFFJ2) {
        var EZS_sF3 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"][
          "\x63\x72\x65\x61\x74\x65\x45\x6c\x65\x6d\x65\x6e\x74"
        ]("\x73\x74\x79\x6c\x65");
        EZS_sF3["\x69\x6e\x6e\x65\x72\x48\x54\x4d\x4c"] = CDEsDFFJ2;
        window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]
          ["\x71\x75\x65\x72\x79\x53\x65\x6c\x65\x63\x74\x6f\x72"](
            "\x62\x6f\x64\x79"
          )
          ["\x61\x70\x70\x65\x6e\x64\x43\x68\x69\x6c\x64"](EZS_sF3);
      }

      function addjs(qGZu4) {
        $("\x62\x6f\x64\x79")["\x61\x70\x70\x65\x6e\x64"](qGZu4);
      }

      function jqban(nJ5) {
        $("\x23\x6a\x71\x62\x62")["\x61\x74\x74\x72"](
          "\x73\x72\x63",
          "\x68\x74\x74\x70\x3a\x2f\x2f\x6c\x69\x62\x73\x2e\x62\x61\x69\x64\x75\x2e\x63\x6f\x6d\x2f\x6a\x71\x75\x65\x72\x79\x2f" +
            nJ5 +
            "\x2f\x6a\x71\x75\x65\x72\x79\x2e\x6d\x69\x6e\x2e\x6a\x73"
        );
      }
    </script>
    <script>
      (function (window, document) {
        var Vector2 = (function () {
          function Vector2(x, y) {
            this.x = x || 0;
            this.y = y || 0;
          }
          return Vector2;
        })();

        Vector2.prototype.add = function (addend) {
          this.x += addend.x;
          this.y += addend.y;
        };

        var RainDrop = (function () {
          function RainDrop(parent) {
            this.size = 2;
            this.parent = parent;
            this.init();
          }
          return RainDrop;
        })();

        RainDrop.prototype.init = function () {
          this.life = 0;
          this.ttl = Math.random() * 500 + 300;
          this.position = new Vector2(Math.random() * window.innerWidth, 0);
          this.velocity = new Vector2(
            0.5 - Math.random() * 1,
            Math.random() * 1 + 0.2
          );
          this.terminalVelocity = 8;
        };

        RainDrop.prototype.update = function () {
          if (
            this.position.x > window.innerWidth ||
            this.position.x < -this.size ||
            this.life > this.ttl
          )
            this.init();
          if (this.position.y > this.parent.floor) {
            this.position.y = this.parent.floor - this.size;
            this.velocity.y *= -0.2 - Math.random() * 0.2;
          }
          this.life++;
          this.position.add(this.velocity);
          this.velocity.y += 0.1;
        };

        var Rain = (function () {
          function Rain(args) {
            this.props = args;
            this.rainDrops = [];
            this.init();
          }
          return Rain;
        })();

        Rain.prototype.init = function () {
          this.createCanvas();
          this.resize();
          this.loop();
        };

        Rain.prototype.resize = function () {
          var attr =
            "position: absolute; z-index: 0; top: 0; left: 0; height: 100vh; width: 100vw;";

          this.canvas.setAttribute("style", attr);

          this.dimensions = {
            width: window.innerWidth,
            height: window.innerHeight,
          };

          this.canvas.width = this.dimensions.width;
          this.canvas.height = this.dimensions.height;
          this.floor = this.dimensions.height * 0.7;
        };

        Rain.prototype.createCanvas = function () {
          this.canvas = document.createElement("canvas");

          this.ctx = this.canvas.getContext("2d");

          document.body.appendChild(this.canvas);
        };

        Rain.prototype.draw = function () {
          this.ctx.fillStyle = this.props.backgroundColor;
          this.ctx.fillRect(0, 0, this.dimensions.width, this.floor);
          for (var i = 0, len = this.rainDrops.length; i < len; i++) {
            var rainDrop = this.rainDrops[i];
            rainDrop.update();
            this.ctx.fillStyle = this.props.rainColor;
            this.ctx.fillRect(
              rainDrop.position.x,
              rainDrop.position.y,
              rainDrop.size,
              rainDrop.size
            );
          }
          this.reflect();
        };

        Rain.prototype.reflect = function () {
          var grad = this.ctx.createLinearGradient(
            this.dimensions.width / 2,
            this.floor * 0.6,
            this.dimensions.width / 2,
            this.floor
          );
          grad.addColorStop(0, "rgba(20,30,40,1)");
          grad.addColorStop(1, "rgba(20,30,40,0)");
          this.ctx.save();
          this.ctx.scale(1, -1);
          this.ctx.translate(0, this.floor * -2);
          this.ctx.filter = "blur(2px) saturate(150%)";
          this.ctx.drawImage(
            this.canvas,
            0,
            0,
            this.dimensions.width,
            this.floor,
            0,
            0,
            this.dimensions.width,
            this.floor
          );
          this.ctx.fillStyle = grad;
          this.ctx.fillRect(0, 0, this.dimensions.width, this.floor);
          this.ctx.restore();
        };

        Rain.prototype.loop = function () {
          var timeout,
            self = this;
          if (self.rainDrops.length < self.props.rainDropCount) {
            timeout = window.setTimeout(function () {
              self.rainDrops.push(new RainDrop(self));
            }, Math.random() * 200);
          } else if (timeout) {
            timeout = null;
            window.clearTimeout(timeout);
          }
          self.draw();
          window.requestAnimationFrame(self.loop.bind(self));
        };

        window.onload = function () {
          var args = {
            rainDropCount: 500,
            rainColor: "rgba(150,180,255,0.8)",
            backgroundColor: "rgba(10,10,10,0.5)",
          };

          var rain = new Rain(args);

          window.onresize = function () {
            rain.resize();
          };
        };

        window.requestAnimationFrame = (function () {
          return (
            window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame ||
            function (callback) {
              window.setTimeout(callback, 1000 / 60);
            }
          );
        })();
      })(this, document);
    </script>
		
	</body>
</html>
